﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using System.Web.Http.Filters;
using NLog;
using NLog.Fluent;

namespace echarts.Filters
{
    public class CustomerExceptionFilterAttribute: ExceptionFilterAttribute
    {
        private Logger logger = LogManager.GetLogger("自定义异常处理");
        public override void OnException(HttpActionExecutedContext actionExecutedContext)
        {
            var exception = actionExecutedContext.Exception;
            actionExecutedContext.Response = actionExecutedContext.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, new HttpError("应用程序发生未知错误"));
            logger.Error("应用程序处理出错：" + exception);
        }
    }
}